package data.visu.structures;

import controls.visu.A_DisplayDataControl;

/**
 * @author Charles Perin
 * 29 mars 2011
 * LIMSI - INRIA Rennes
 * charles.perin@free.fr
 *
 */
public class Range extends Object implements Comparable<Object> {

	protected int min;
	protected int max;
	protected A_DisplayDataControl a_DisplayDataControl;

	public Range(int min, int max, A_DisplayDataControl a_DisplayDataControl) {
		if (min < max) {
			this.min = min;
			this.max = max;
		}
		setDisplayDataControl(a_DisplayDataControl);
	}

	public void setMin(int min) {
		if (min < this.max) {
			this.min = min;
		}
	}

	public int getMin() {
		return this.min;
	}

	public void setMax(int max) {
		if (max > this.min) {
			this.max = max;
		}
	}

	public int getMax() {
		return this.max;
	}

	public String toString() {
		if(a_DisplayDataControl!=null)return "(min:" + this.min + " , max:" + this.max + ", a_DisplayData:"+a_DisplayDataControl.getName()+") ";
		else return "(min:" + this.min + " , max:" + this.max + "), a_DisplayData: null) ";
	}

	@Override
	public int compareTo(Object o) {
		int compMin = ((Range) o).getMin();
		return this.min - compMin;
	}

	public void setDisplayDataControl(A_DisplayDataControl a_DisplayDataControl) {
		this.a_DisplayDataControl = a_DisplayDataControl;
	}

	public A_DisplayDataControl getDisplayDataControl() {
		return a_DisplayDataControl;
	}
}
